<template>
  <el-aside id="infoAside" style=" width: 70px;">
    <div class="text-align-center flex flex-column m-t-10 m-b-10">
      <div>
        <h5>用户</h5>
        <el-avatar shape="square" :size="60" :src="userInfo.icon"></el-avatar>
        <div class="word-wrap">{{userInfo.username}}</div>
        <el-button type="text" @click="logOut">退出</el-button>
      </div>
    </div>
    <div class="text-align-center m-b-15">
      <h5>博客中文</h5>
      <p>{{webInfo.zhName}}</p>
    </div>
    <div class="text-align-center m-b-15">
      <h5>博客英文</h5>
      <p>{{webInfo.engName}}</p>
    </div>
    <div class="text-align-center m-b-15">
      <h5>博客Logo</h5>
      <el-avatar shape="square" :size="60" :src="webInfo.iconUrl"></el-avatar>
    </div>
    <div class="text-align-center m-b-15">
      <h5>站长</h5>
      <p>{{webInfo.master}}</p>
    </div>
  </el-aside>
</template>

<script>
import Icon from './Icon'
export default {
  components: {
    Icon
  },
  created() {
    this.getPresenalInfo()
    this.getWebInfo()
  },
  data() {
    return {
      name: localStorage.username,
      userInfo:{},
      webInfo: {}
    }
  },
  methods: {
    logOut() {
      this.$confirm('是否退出登录?', '退出提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        localStorage.clear()
        sessionStorage.clear()
        this.$router.push({path: '/'})
        this.$message({type: 'success',message: '退出成功!'})
      }).catch(() => {
        this.$message({type: 'info',message: '取消退出'});         
      })
    },
    async getPresenalInfo() {
      let res = await this.api.get('/admin/getUserInfoById', {
          params: {id: localStorage.id}
      })
      if (res.code == 0) this.userInfo = res.data   
    },
    async getWebInfo() {
      let res = await this.api.get('/getWebsiteInfo')
      if (res.code == 0) this.webInfo = res.data
      console.log('9999999999',this.webInfo)   
    },
  }
}
</script>

<style lang="scss">
#infoAside {
  box-shadow: -2px 0px 5px #bbb;
}
</style>